using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using UwinEducation.Shared.Converters;
using UwinEducation.Shared.Enums;

namespace UwinEducation.Application.Dtos.Orders
{
    /// <summary>
    /// 订单支付数据传输对象
    /// </summary>
    public class OrderPaymentDto
    {
        /// <summary>
        /// 支付ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 订单ID
        /// </summary>
        public Guid OrderId { get; set; }

        /// <summary>
        /// 支付金额
        /// </summary>
        public decimal Amount { get; set; }

        /// <summary>
        /// 支付时间
        /// </summary>
        public DateTime PaymentTime { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        public PaymentMethod PaymentMethod { get; set; }

        /// <summary>
        /// 审核状态
        /// </summary>
        public AuditStatus AuditStatus { get; set; }

        /// <summary>
        /// 支付凭证号/流水号
        /// </summary>
        public string TransactionNumber { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatorName { get; set; }
        /// <summary>
        /// 审核人
        /// </summary>
        public string AuditorName { get; set; }

        public StudentDto Student { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remarks { get; set; }

        ///// <summary>
        ///// 订单编号 (通过关联获取)
        ///// </summary>
        //public string OrderNumber { get; set; }
    }

    /// <summary>
    /// 创建订单支付数据传输对象
    /// </summary>
    public class CreateOrderPaymentDto
    {
        /// <summary>
        /// 订单ID
        /// </summary>
        [Required(ErrorMessage = "订单ID不能为空")]
        public Guid OrderId { get; set; }

        /// <summary>
        /// 学生ID
        /// </summary>
        [Required(ErrorMessage = "学生ID不能为空")]
        public Guid StudentId { get; set; }

        /// <summary>
        /// 支付金额
        /// </summary>
        [Required(ErrorMessage = "支付金额不能为空")]
        public decimal Amount { get; set; }

        /// <summary>
        /// 支付时间
        /// </summary>
        [Required(ErrorMessage = "支付时间不能为空")]
        public DateTime PaymentDate { get; set; }

        /// <summary>
        /// 支付方式
        /// </summary>
        [Required(ErrorMessage = "支付方式不能为空")]
        public PaymentMethod PaymentMethod { get; set; }

        /// <summary>
        /// 支付凭证号/流水号
        /// </summary>
        [Required(ErrorMessage = "支付凭证号/流水号不能为空")]
        public string TransactionId { get; set; }

        /// <summary>
        /// 创建人ID
        /// </summary>
        [Required(ErrorMessage = "创建人ID不能为空")]
        public Guid CreatorId { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
    }

    /// <summary>
    /// 更新订单支付数据传输对象
    /// </summary>
    public class UpdateOrderPaymentDto
    {
        /// <summary>
        /// 支付ID
        /// </summary>
        [Required(ErrorMessage = "支付ID不能为空")]
        public Guid Id { get; set; }

        /// <summary>
        /// 审核人ID
        /// </summary>
        [Required(ErrorMessage = "审核人ID不能为空")]
        public Guid AuditorId { get; set; }
        /// <summary>
        /// 审核状态
        /// </summary>
        [Required(ErrorMessage = "审核状态不能为空")]
        public AuditStatus AuditStatus { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
    }

    /// <summary>
    /// 订单支付分页请求DTO
    /// </summary>
    public class OrderPaymentPageRequestDto
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 10;

        /// <summary>
        /// 订单ID (可选筛选条件)
        /// </summary>
        public Guid? OrderId { get; set; }

        /// <summary>
        /// 支付方式 (可选筛选条件)
        /// </summary>
        public PaymentMethod? PaymentMethod { get; set; }

        /// <summary>
        /// 审核状态 (可选筛选条件)
        /// </summary>
        public AuditStatus? AuditStatus { get; set; }

        /// <summary>
        /// 最小支付金额 (可选筛选条件)
        /// </summary>
        public decimal? MinAmount { get; set; }

        /// <summary>
        /// 最大支付金额 (可选筛选条件)
        /// </summary>
        public decimal? MaxAmount { get; set; }

        /// <summary>
        /// 支付开始日期 (可选筛选条件)
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 支付结束日期 (可选筛选条件)
        /// </summary>
        [JsonConverter(typeof(CustomDateTimeConverter))]
        public DateTime? EndDate { get; set; }

        /// <summary>
        /// 搜索关键词 (用于订单号、凭证号或备注)
        /// </summary>

        public string? SearchTerm { get; set; }
    }
} 